<?php
	class LoginController extends Controller{
		private $model;
		public function __init(){
			$this->model = K('user');
		}
		// public function login(){
		// 	$this->display();
		// }
		public function register(){
			if(IS_POST){
				if($this->model->addUser()){
					$this->success('注册成功',U('Login/login'));
				}else{
					$this->success('注册失败');
				}
			}else{
				$this->display();
			}
			// p($_POST);
		}
		public function login(){
			if(IS_POST){
				if($re=$this->model->checkUser()){
					$_SESSION['user']=$re;
					$this->success('登陆成功',U('Index/index'));
				}else{
					// p($re);
					$this->error('用户名密码错误');
				}
			}
			$this->display();
		}
	}
?>